import Page
from Page import Service
from Base.Base import Base
from selenium.webdriver.common.by import By


class ServiceDrivingScorePage(Base):
    """
    驾驶评分页
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.driving_home_btn = (By.XPATH, Service.RESOURCE_ID_Driving.format("ivHome"))

        # 左侧的返回键
        self.driving_back_btn = (By.XPATH, Service.RESOURCE_ID_Driving.format('ivBack'))

        # 驾驶评分标题
        self.driving_score_title_text = (By.XPATH, Page.TEXT.format("驾驶评分"))

        # 驾驶评分
        self.driving_score_number_text = (By.XPATH, Service.RESOURCE_ID_Driving.format("tv_drive_score"))

        # 行驶里程数字
        self.driving_distance_number_text = (By.XPATH, Service.RESOURCE_ID_Driving.format("tv_travel_odograph"))

        # 平均车速数字
        self.driving_average_speed_number_text = (By.XPATH, Service.RESOURCE_ID_Driving.format("tv_avg_speed"))

        # 百公里油耗数字
        self.driving_fuel_consumption_kilometers_number_text = (
        By.XPATH, Service.RESOURCE_ID_Driving.format("tv_avg_oil"))

        # 急加速
        self.driving_rapid_acceleration_text = (By.XPATH, Service.RESOURCE_ID_Driving.format("tv_accelerate_time"))

        # 急减速
        self.driving_rapid_deceleration_text = (By.XPATH, Service.RESOURCE_ID_Driving.format("tv_deceleration_time"))

        # 急转弯
        self.driving_sharp_turn_text = (By.XPATH, Service.RESOURCE_ID_Driving.format("tv_sharp_turn_time"))

        # 功能提示按钮
        self.driving_function_tips_btn = (By.XPATH, Service.RESOURCE_ID_Driving.format("tv_tips"))

        # 平均车速按钮
        self.driving_average_speed_btn = (By.XPATH, Service.RESOURCE_ID_Driving.format("rb_avg_speed"))

        # 平均油耗按钮
        self.driving_average_fuel_consumption_btn = (
        By.XPATH, Service.RESOURCE_ID_Driving.format("rb_avg_oil_consumption"))

        # 更多记录按钮
        self.driving_more_records_btn = (By.XPATH, Service.RESOURCE_ID_Driving.format("tv_history_record"))

        # 折线图
        self.driving_line_chart_img = (By.XPATH, Service.RESOURCE_ID_Driving.format("lc_snap_speed"))

        # 功能提示标题
        self.driving_function_tips_text = (By.XPATH, Service.RESOURCE_ID_Driving.format("tv_tips_title"))

        # 功能提示内容
        self.driving_function_content_text = (By.XPATH, Service.RESOURCE_ID_Driving.format("tv_tips_content"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.driving_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.driving_back_btn)

    def get_score_title(self):
        """
        获取驾驶评分标题

        :return:获取元素
        """
        return self.find_element_o(self.driving_score_title_text)

    def get_score_number(self):
        """
        获取驾驶评分

        :return:获取元素
        """
        return self.find_element_o(self.driving_score_number_text)

    def get_distance_number(self):
        """
        获取行驶里程数字

        :return:获取元素
        """
        return self.find_element_o(self.driving_distance_number_text)

    def get_average_speed_number(self):
        """
        获取平均车速数字

        :return:获取元素
        """
        return self.find_element_o(self.driving_average_speed_number_text)

    def get_fuel_consumption_kilometers_number(self):
        """
        获取百公里油耗数字

        :return:获取元素
        """
        return self.find_element_o(self.driving_fuel_consumption_kilometers_number_text)

    def get_rapid_acceleration(self):
        """
        获取急加速数字

        :return:获取元素
        """
        return self.find_element_o(self.driving_rapid_acceleration_text)

    def get_rapid_deceleration(self):
        """
        获取急减速数字

        :return:获取元素
        """
        return self.find_element_o(self.driving_rapid_deceleration_text)

    def get_sharp_turn(self):
        """
        获取急转弯数字

        :return:获取元素
        """
        return self.find_element_o(self.driving_sharp_turn_text)

    def click_function_tips(self):
        """
        点击功能提示按钮

        :return:获取元素
        """
        self.click_element(self.driving_function_tips_btn)

    def click_average_speed(self):
        """
        点击平均车速按钮

        :return:获取元素
        """
        self.click_element(self.driving_average_speed_btn)

    def get_average_speed(self):
        """
        获取平均车速按钮属性

        :return:获取元素
        """
        return self.find_element_o(self.driving_average_speed_btn)

    def click_average_fuel_consumption(self):
        """
        点击平均油耗按钮

        :return:获取元素
        """
        self.click_element(self.driving_average_fuel_consumption_btn)

    def get_average_fuel_consumption(self):
        """
        获取平均油耗按钮属性

        :return:获取元素
        """
        return self.find_element_o(self.driving_average_fuel_consumption_btn)

    def click_more_records(self):
        """
        点击更多记录按钮

        :return:获取元素
        """
        self.click_element(self.driving_more_records_btn)

    def get_line_chart(self):
        """
        获取折线图

        :return:获取元素
        """
        return self.find_element_o(self.driving_line_chart_img)

    def get_function_tips(self):
        """
        获取功能提示标题

        :return:获取元素
        """
        return self.find_element_o(self.driving_function_tips_text)

    def get_function_content(self):
        """
        获取功能提示内容

        :return:获取元素
        """
        return self.find_element_o(self.driving_function_content_text)

    def is_display_driving_function(self):
        """
        是否进入驾驶评分的功能提示页

        :return: bool
        """
        return self.is_display(self.driving_function_tips_text)

    def is_display_driving_score(self):
        """
        是否进入驾驶评分界面

        :return: bool
        """
        return self.is_display(self.driving_score_title_text)
